import 'dart:math';

import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:appscheme/appscheme.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:smart_freezer/core/model/banner_model.dart';
import 'package:smart_freezer/core/model/product_model.dart';
import 'package:smart_freezer/core/resources/app_config.dart';
import 'package:smart_freezer/core/resources/icon_names.dart';
import 'package:smart_freezer/core/resources/routers.dart';
import 'package:smart_freezer/core/service/api/app_api.dart';
import 'package:smart_freezer/core/service/service/result_data.dart';
import 'package:smart_freezer/core/utils/extension/all_extension.dart';
import 'package:smart_freezer/core/utils/lc_event_bus/call.dart';
import 'package:smart_freezer/core/utils/local_storage.dart';
import 'package:smart_freezer/core/utils/logs.dart';
import 'package:smart_freezer/core/utils/tr_extension.dart';
import 'package:smart_freezer/core/view/update_params.dart';
import 'package:smart_freezer/generated/locale_keys.g.dart';
import 'package:ty_smart_home/ty_smart_home.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../core/utils/color_util.dart';
import '../../core/utils/lc_event_bus/notify.dart';

class HomeContentPage extends StatefulWidget {
  const HomeContentPage({Key? key}) : super(key: key);

  @override
  State<HomeContentPage> createState() => _HomeContentPageState();
}

class _HomeContentPageState extends State<HomeContentPage> {

  // List _dataList = [""];
  List<BannerModel> _bannerList = [];
  List<ProductModel> _productList = [];
  int currentPage = 0;

  EasyRefreshController _refreshController = EasyRefreshController();
  // -1为默认, 0为编号, 1为型号, 2为位置
  int sortType = 0;
  bool isColumn = true;

  var searchTextController = TextEditingController();
  FocusNode _searchFocusNode = FocusNode();

  bool isDarkMode = LocalStorage.getThemeMode() == 1;

  static AppScheme appScheme = AppSchemeImpl.getInstance() as AppScheme;

  List<ProductModel> _sortedProductList = [];

  @override
  void initState() {
    super.initState();
    _getBannerData();
    // _getNewList();

    // 设备分享处理
    _dealwithShareContent();

    Call.addCallBack(Notify.dark_mode, (data){
      setState((){});
      isDarkMode = LocalStorage.getThemeMode() == 1;
    });

    // 注册推送ID和语言
    _saveRegisterId();

  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: isDarkMode ? null : Color(0xFFF1F3F8),
      child: Column(
        children: [
          // 轮播图
          _bannerList.isNotEmpty ?
          Container(
            margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
            height: MainCommon.screenWidth * 0.8 / 16 * 9,
            child: Swiper(
              itemBuilder: (BuildContext context, int index) {
                final bannerModel = _bannerList[index];
                return Card(
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), // 设置圆角
                  clipBehavior: Clip.antiAlias,
                  child: InkWell(
                    onTap: () {
                      _launchURL(bannerModel.forwardUrl);
                    },
                    child: CachedNetworkImage(
                      fit: BoxFit.fitWidth,
                      placeholder: (ctx, url) => Image.asset(IconNames.test_bg0, fit: BoxFit.fill,),
                      imageUrl: bannerModel.logo,
                      errorWidget: (ctx, url, _) => Image.asset(IconNames.test_bg0, fit: BoxFit.fill),
                    ),
                  ),
                  elevation: 5,
                );
              },
              itemCount: _bannerList.length,
              viewportFraction: 0.8,
              scale: 0.9,
              onTap: (index) {

              },
            ),
          ) : Container(),

          // 我的设备
          Container(
            margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(LocaleKeys.add_device_my_device.trc(), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),),
                Row(
                  children: [
                    _searchWidget(),
                    SizedBox(width: 5,),
                    InkWell(
                        onTap: () {  // 排序
                          showModalBottomSheet<void>(
                              context: context,
                              shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.only(
                                  topLeft: Radius.circular(20),
                                  topRight: Radius.circular(20),
                                ),
                              ),
                              builder: (BuildContext context) {
                                final list = [LocaleKeys.device_info_bianhao.trc(), LocaleKeys.device_info_device_xinghao.trc(), LocaleKeys.device_info_weizhi.trc(), ];
                                return UpdateParams(
                                  valueList: list,
                                  onSelectedValue: (String value) {
                                    Navigator.pop(context);
                                    logs("$value");

                                    _productList = [];
                                    currentPage = 1;
                                    final index = list.indexOf(value);
                                    _getDeviceList(currentPage, sortType: index);
                                  },
                                );
                              });
                        },
                        child: Image.asset(IconNames.home_material03, height: 30,)
                    ),
                    SizedBox(width: 5,),
                    InkWell(
                        onTap: () {   // 横纵列
                          isColumn = !isColumn;
                          logs("isColumn: $isColumn");
                          setState(() {});
                        },
                        child: Image.asset(IconNames.home_material, height: 30,)
                    ),
                  ],
                )
              ],
            ),
          ),

          // 冰柜列表
          Expanded(
            child: _getEasyRefreshView(),
          ),

        ],
      ),
    );
  }

  _getEasyRefreshView() {
    if(isColumn == false) {
      return EasyRefresh(
        controller: _refreshController,
        header: MaterialHeader(valueColor: AlwaysStoppedAnimation(isDarkMode ? Colors.white : Colors.black)),
        footer: MaterialFooter(valueColor: AlwaysStoppedAnimation(isDarkMode ? Colors.white : Colors.black)),
        firstRefresh: true,
        emptyWidget: _sortedProductList.isEmpty ? Center(
          child: Column(
            children: [
              SizedBox(height: 50,),
              Image.asset(IconNames.home_w06, width: MainCommon.screenWidth * 0.6, height: MainCommon.screenWidth * 0.6,),
              Text(LocaleKeys.other_add_device_tip.trc(), style: TextStyle(color: Colors.grey), textAlign: TextAlign.center,),
            ],
          ),
        ) : null,
        onLoad: () async {
          _getMoreList();
        },
        onRefresh: () async {
          logs("onRefresh");
          _getBannerData();
          _getNewList();
        },
        child: GridView(
          padding: EdgeInsets.fromLTRB(15, 10, 15, 0),
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            childAspectRatio: 160 / 194,
            crossAxisSpacing: 10,
            mainAxisSpacing: 10,
          ),
          children: List.generate(_sortedProductList.length, (index) {
            final productModel = _sortedProductList[index];

            return InkWell(
              onTap: () {
                Get.toNamed(LCRouter.device_detail, arguments: productModel.id)?.then((value) {
                  _getBannerData();
                  _getNewList();

                  isDarkMode = LocalStorage.getThemeMode() == 1;
                });
              },
              child: RowWidget(productModel: productModel,)
            );
          }),
        ),

      );
    }else if(isColumn == true){
      return EasyRefresh.custom(
        controller: _refreshController,
        header: MaterialHeader(valueColor: AlwaysStoppedAnimation(isDarkMode ? Colors.white : Colors.black)),
        footer: MaterialFooter(valueColor: AlwaysStoppedAnimation(isDarkMode ? Colors.white : Colors.black)),
        firstRefresh: true,
        emptyWidget: _sortedProductList.isEmpty ? Center(
          child: Column(
            children: [
              SizedBox(height: 50,),
              Image.asset(IconNames.home_w06, width: MainCommon.screenWidth * 0.6, height: MainCommon.screenWidth * 0.6),
              Text(LocaleKeys.other_add_device_tip.trc(), style: TextStyle(color: Colors.grey), textAlign: TextAlign.center,),
            ],
          ),
        ) : null,
        slivers: [
          SliverList(
            delegate: SliverChildBuilderDelegate(
                  (context, index) {
                final productModel = _sortedProductList[index];
                logs("productModel.code: ${productModel.code} => ${productModel.serialNumber} => index: ${index}");

                return InkWell(
                    onTap: () {
                      Get.toNamed(LCRouter.device_detail, arguments: productModel.id)?.then((value) {
                        _getBannerData();
                        _getNewList();

                        isDarkMode = LocalStorage.getThemeMode() == 1;
                      });
                    },
                    child: ColumnWidget(productModel: productModel,),
                );
              },
              childCount: _sortedProductList.length,
            ),
          ),
        ],
        onLoad: () async {
          _getMoreList();
        },
        onRefresh: () async {
          logs("onRefresh");
          _getBannerData();
          _getNewList();
        },
      );
    }
  }

  /// 搜索设备
  _searchWidget() {

    return Container(
        height: 30,
        width: 150,
        // color: Colors.red,
        // padding: EdgeInsets.fromLTRB(0, 0, 0, 5),
        child: Container(
          decoration: BoxDecoration(
            color: Color(0xFFF7F7F7),
            borderRadius: const BorderRadius.all(
              Radius.circular(15.0),
            ),
          ),
          // alignment: Alignment.center,
          child: Padding(
            padding: const EdgeInsets.only(
                left: 20, right: 20, top: 0, bottom: 0),
            child: TextField(
              onChanged: (String txt) {
                // 搜索数据

              },
              style: TextStyle(
                fontSize: 15,
                color: Colors.black54,
              ),
              textInputAction: TextInputAction.search,
              controller: searchTextController,
              // cursorColor: HexColor('#54D3C2'),  // 光標顏色
              onEditingComplete: () {
                _searchFocusNode.unfocus();
                // 搜索数据
                _getNewList();
              },
              focusNode: _searchFocusNode,

              decoration: InputDecoration(
                border: InputBorder.none,
                hintText: "${LocaleKeys.device_info_bianhao.trc()}/${LocaleKeys.device_info_xinghao.trc()}",

                contentPadding: EdgeInsets.fromLTRB(0, 0, 0, 11),
                prefixIcon: Icon(Icons.search,color: Colors.grey.shade300,),
                alignLabelWithHint: true,

                hintStyle:TextStyle(
                  height: 2,
                  fontSize: 13,
                  color: Colors.grey.shade300,
                ),
              ),

            ),
          ),
        ),
      );
  }

  void _launchURL(String url) async {
    final _url = Uri.parse(url);
    if (!await launchUrl(_url)) throw 'Could not launch $_url';
  }

  // 获取轮播图数据
  _getBannerData() async {
    ResultData data = await AppApi.getInstance().getBannerData();
    if(data.code == 0){
      final list = data.data["bannerList"] as List;
      final modelList = list.map((e) => BannerModel.fromJson(e)).toList();
      _bannerList = modelList;
      setState(() {});
    }else {
      SmartDialog.showToast(data.msg);
    }
  }

  _getNewList() {
    _productList = [];
    currentPage = 1;
    _getDeviceList(currentPage);

    // 获取设备列表
    TySmartHome.getDeviceList().then((value) {
      // logs("首页设备: $value");
      // TySmartHome.updateDeviceDPS("6c48dadf11579c4b9dmztc", "BW_SL", 2);
    });
  }
  _getMoreList() {
    currentPage += 1;
    _getDeviceList(currentPage);
  }

  // 获取设备列表
  _getDeviceList(int page, {int sortType = -1}) async {
    final params = {"page": "$page", "limit": "20"};
    if(searchTextController.text.isNotEmpty){
      params.addAll({"queryFuzzy": searchTextController.text});
    }
    ResultData data = await AppApi.getInstance().getProductList(params);
    if(data.code == 0){
      final list = data.data as List;
      if(list.isEmpty) return;

      final modelList = list.map((e) => ProductModel.fromJson(e)).toList();
      if(currentPage == 1) {
        _productList = modelList;
      }else{
        _productList.addAll(modelList);
      }

      if(sortType == 0) {
        _productList.sort((left, right) => left.code.compareTo(right.code));
      }else if(sortType == 1) {
        _productList.sort((left, right) => left.modelName.compareTo(right.modelName));
      }else if(sortType == 2) {
        _productList.sort((left, right) => left.hallName.compareTo(right.hallName));
      }

      _sortedProductList = _productList;
      setState((){});
      return;
      _productList.forEach((element) async {
        final params = {"productId": "${element.id}"};
        final index = _productList.indexOf(element);
        ResultData data = await AppApi.getInstance().getProductInfo(params);
        if(data.code == 0){
          var model = ProductModel.fromJson(data.data);
          model.icon = element.icon;
          model.productId = element.id;

          _productList[index] = model;
          if(index == _productList.length - 1){
            // 报警消息置顶 无需排序
            // _productList.sort((left, right) {
            //   return right.warnTag.compareTo(left.warnTag);
            // });

            _sortedProductList = _productList.deepCopy.map((e) => e as ProductModel).toList();
            setState((){});
          }
        }
      });

    }else {
      SmartDialog.showToast(data.msg);
    }
  }

  /// 保存分享, status: 2为接受邀请, 3为拒绝邀请
  _acceptDeviceShare(String status, String shareId, int tyShareId) async {
    SmartDialog.show(builder: (_){return Container();});  // 提前唤醒dialog, 如果不增加此段代码, 下面的dialog不会显示

    final params = {"shareId": shareId, "status": status};
    ResultData data = await AppApi.getInstance().acceptShareInfo(params);
    if(data.code == 0){
      TySmartHome.confirmShareInviteShare(tyShareId);
      _getNewList();
    }else {
      // logs("保存分享: ${data.msg}");
      SmartDialog.showToast(data.msg, displayTime: Duration(seconds: 2));
    }
  }

  _dealwithShareContent(){
    appScheme.getInitScheme().then((value) {
      if (value != null) {
        final string = "Init  ${value.dataString} map:${value.query}";
        logs("getInitScheme: $string");
      }
    });

    appScheme.getLatestScheme().then((value) {
      if (value != null) {
        final string = "Latest ${value.dataString}  map:${value.query}";
        logs("getLatestScheme: $string");
        if(value.query?.containsKey("tuyaShareId") == true && value.query?.containsKey("williamShareId") == true){
          final tyShareId = int.tryParse(value.query!["tuyaShareId"].toString()) ?? 0;
          final shareId = value.query!["williamShareId"].toString();
          final localShareId = LocalStorage.getWilliamShareID();
          if(localShareId != shareId){
            _showDealwithShareDialog(shareId, tyShareId);
            LocalStorage.setWilliamShareID(shareId);
          }
        }

      }
    });

    // 外界唤醒App, 数据监听
    appScheme.registerSchemeListener().listen((value) {
      if (value != null) {
        final string = "listen ${value.dataString}  map:${value.query}";
        logs("registerSchemeListener: $string");

        if(value.query?.containsKey("tuyaShareId") == true && value.query?.containsKey("williamShareId") == true){

          final tyShareId = int.tryParse(value.query!["tuyaShareId"].toString()) ?? 0;
          final shareId = value.query!["williamShareId"].toString();

          _showDealwithShareDialog(shareId, tyShareId);

        }
      }
    });

    // Call.addCallBack(Notify.share_accept, (data) {
    //   logs("data: $data");
    //   showOkCancelAlertDialog(
    //       context: context,
    //       message: LocaleKeys.other_share_tip.trc()
    //   ).then((value) {
    //     final acceptStatus = value == OkCancelResult.ok ? "2": "3";
    //
    //     final shareId = data["shareId"];
    //     final tyShareId = data["tyShareId"];
    //     _acceptDeviceShare(acceptStatus, shareId, tyShareId);
    //   });
    // });

  }

  _showDealwithShareDialog(String shareId, int tyShareId) {
    Future.delayed(Duration(seconds: 1)).then((value) {
      logs("打开邀请分享窗口");
      showOkCancelAlertDialog(
        context: context,
        message: LocaleKeys.other_share_tip.trc(),
        builder: (context, child) => Theme(
          data: ThemeData(
              primarySwatch: createMaterialColor(isDarkMode ? Colors.white : Colors.black),
              dialogBackgroundColor: isDarkMode ? MainCommon.darkBlueMaterialColor : Colors.white,
              colorScheme: ColorScheme(
                primary: isDarkMode ? Colors.white : Colors.black, // 文字颜色
                primaryVariant: Colors.white,
                secondary: Colors.green,
                background: Colors.white,
                error: Colors.red,
                brightness: isDarkMode ? Brightness.dark : Brightness.light,    /// 最最关键
                onBackground: Colors.pink,
                secondaryVariant: Colors.white,
                onError: Colors.yellow,
                onPrimary: Colors.red, //顶部栏字体颜色
                onSecondary: Colors.black,
                onSurface: Colors.white,   // 导航栏字体颜色, 返回按钮颜色
                surface: MainCommon.darkBlueMaterialColor,  // 导航栏背景颜色
              )),
          child: child,
        ),
      ).then((value) {
        final acceptStatus = value == OkCancelResult.ok ? "2": "3";
        _acceptDeviceShare(acceptStatus, shareId, tyShareId);
      });
    });
  }


  _saveRegisterId() async {
    final params = {
      "registrationId": LocalStorage.getRegisterID(),
      "languages": LocalStorage.getLanguageValue().toString()
    };
    ResultData data = await AppApi.getInstance().saveRegisterId(params);
    if(data.code == 0){

    }else{
      SmartDialog.showToast(data.msg);
    }
  }


}

class RowWidget extends StatelessWidget {
  final ProductModel productModel;

  const RowWidget({
    Key? key,
    required this.productModel,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // 温度过高/过低
    bool isNotNormal = productModel.highTemperature.isNotEmpty || productModel.lowerTemperature.isNotEmpty ||
                       productModel.t1Failure.isNotEmpty || productModel.t2Failure.isNotEmpty || productModel.t3Failure.isNotEmpty ||
                       productModel.condenserClean.isNotEmpty || productModel.doorOpen.isNotEmpty;
    bool isMoreHigh = productModel.highTemperature.isNotEmpty;

    return Container(
      // height: 74.h,
      // width: 160.w,
      child: Card(
        child: Container(
          padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text("${productModel.code} ${productModel.modelName}", style: TextStyle(fontWeight: FontWeight.bold),),

              Text("${productModel.name}", style: TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.left,),

              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      CircleAvatar(
                        backgroundColor: productModel.networkStatus == 1 ? Colors.green : Colors.grey,
                        radius: 5,
                      ),
                      Text("T1: ${productModel.networkStatus == 1 ? "${productModel.temperatureOne}℃" : "--"}", style: TextStyle(color: Colors.grey),)
                    ],
                  ),
                  Container(
                    decoration: BoxDecoration(
                      color: productModel.networkStatus == 1 ? (isNotNormal ? Colors.red.shade50 : Colors.green.shade50) : Colors.grey.shade200,
                      borderRadius: BorderRadius.circular(5),
                    ),
                    padding: EdgeInsets.fromLTRB(5, 2, 5, 3),
                    constraints: BoxConstraints(
                      maxWidth: productModel.networkStatus == 1 ? (isNotNormal ? MainCommon.screenWidth * 0.11 : double.infinity) : double.infinity,
                    ),
                    alignment: Alignment.center,
                    child: Text("${productModel.warningMessage}",
                      style: TextStyle(color: productModel.networkStatus == 1 ? (isNotNormal ? Colors.red : Colors.green) : Colors.grey, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis,),
                  ),
                ],
              ),

              // 冰柜背景
              Expanded(
                // color: Colors.red,
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Expanded(
                      child: Container(
                        height: 90,
                        child: Stack(
                          alignment: Alignment.center,
                          children: [
                            Image.asset(IconNames.home_xzbg, width: 90,),
                            Positioned(
                                child: Container(
                                  // width: 50,
                                  child: CachedNetworkImage(
                                    fit: BoxFit.fitWidth,
                                    placeholder: (ctx, url) => Image.asset(IconNames.home_sb_a, fit: BoxFit.fill, width: 50),
                                    imageUrl: productModel.icon,
                                    errorWidget: (ctx, url, _) => Image.asset(IconNames.home_sb_a, fit: BoxFit.fill, width: 50 ),
                                  ),
                                  // Image.asset(IconNames.home_sb_a, width: 70,),
                                )
                            )

                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),

              // 地点
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Image.asset(IconNames.home_positioning, height: 20,),
                  Text("${productModel.hallName} ${productModel.floorName}", style: TextStyle(color: Colors.grey),),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

class ColumnWidget extends StatelessWidget {

  final ProductModel productModel;
  const ColumnWidget({
    Key? key,
    required this.productModel,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    // 温度过高/过低
    bool isNotNormal = productModel.highTemperature.isNotEmpty || productModel.lowerTemperature.isNotEmpty ||
                       productModel.t1Failure.isNotEmpty || productModel.t2Failure.isNotEmpty || productModel.t3Failure.isNotEmpty ||
                       productModel.condenserClean.isNotEmpty || productModel.doorOpen.isNotEmpty;

    bool isMoreHigh = productModel.highTemperature.isNotEmpty;   // false; //

    return Card(
      margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
      // shape: ,
      child: Container(
        padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
        child: Row(
          children: [
            // 冰柜背景
            Stack(
              alignment: Alignment.center,
              children: [
                Image.asset(IconNames.home_xzbg, width: 70, height: 70, ),
                Positioned(
                    child: Container(
                      width: 70,
                      // height: 70,
                      child: CachedNetworkImage(
                        fit: BoxFit.fitWidth,
                        placeholder: (ctx, url) => Image.asset(IconNames.home_sb_a, fit: BoxFit.fill, width: 70),
                        imageUrl: productModel.icon,
                        errorWidget: (ctx, url, _) => Image.asset(IconNames.home_sb_a, fit: BoxFit.fill, width: 70 ),
                      ),
                      // Image.asset(IconNames.home_sb_a, width: 70,),
                    )
                )

              ],
            ),

            SizedBox(width: 5,),
            // 第二列
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [

                Container(
                  constraints: BoxConstraints(
                    maxWidth: 250,
                  ),
                    child: Text("${productModel.code} ${productModel.modelName} ${productModel.name}", style: TextStyle(fontWeight: FontWeight.bold),)
                ),

                Container(
                  width: MainCommon.screenWidth - 110,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          CircleAvatar(
                            backgroundColor: productModel.networkStatus == 1 ? Colors.green : Colors.grey,
                            radius: 4,
                          ),
                          SizedBox(width: 5,),
                          Text("T1: ${productModel.networkStatus == 1 ? "${productModel.temperatureOne}℃" : "--"}", style: TextStyle(color: Colors.grey),)
                        ],
                      ),

                      Row(
                        children: [
                          Container(
                            decoration: BoxDecoration(
                              color: productModel.networkStatus == 1 ? (isNotNormal ? Colors.red.shade50 : Colors.green.shade50) : Colors.grey.shade200,
                              borderRadius: BorderRadius.circular(5),
                            ),
                            padding: EdgeInsets.fromLTRB(5, 2, 5, 3),
                            constraints: BoxConstraints(
                              maxWidth: productModel.networkStatus == 1 ? (isNotNormal ? MainCommon.screenWidth * 0.3 : double.infinity) : double.infinity,
                            ),
                            alignment: Alignment.center,
                            child: Text("${productModel.warningMessage}",
                              style: TextStyle(color: productModel.networkStatus == 1 ? (isNotNormal ? Colors.red : Colors.green) : Colors.grey, fontSize: 12,), maxLines: 1, overflow: TextOverflow.ellipsis,),
                          ),

                          Icon(Icons.chevron_right, color: Colors.grey,),
                        ],
                      ),

                    ],
                  ),
                ),

                // 地点
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Image.asset(IconNames.home_positioning, height: 20,),
                    Text("${productModel.hallName} ${productModel.floorName}", style: TextStyle(color: Colors.grey),),
                  ],
                ),
              ],
            ),

          ],
        ),
      ),
    );
  }

}
